//
//  ViewController.m
//  UI26-Masonry
//
//  Created by 韩旭 on 16/8/18.
//  Copyright © 2016年 lanou. All rights reserved.

#import "ViewController.h"
#import "Masonry.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    使用Massonry ， 不用给出事frame
    self.view.backgroundColor = [UIColor whiteColor];
    UIView *view = [UIView new];
    view.backgroundColor = [UIColor redColor];
    UIView *view2 = [UIView new];
    view2.backgroundColor = [UIColor blueColor];
    UIView *view3 = [UIView new];
    view3.backgroundColor = [UIColor greenColor];
    //        添加约束前，需要把视图添加到父视图上
    [self.view addSubview:view];
    [view addSubview:view2];
    [view addSubview:view3];
//    设置该视图的约束
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    [view2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(view.mas_width).multipliedBy(0.5f);
        make.height.mas_equalTo(self.view.mas_width).multipliedBy(0.6f);
    }];
//    添加换色视图，宽高与蓝色相同，与蓝色相聚10
    [view3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.centerX.mas_equalTo(view2).multipliedBy(0.5f);
        make.top.mas_equalTo(view2.mas_bottom).mas_offset(10);
        
    }];
//    系统的方法
//    UILabel *yellowView = [UILabel new];
//    yellowView.left = self.view * 1.0f + 0;
//    [NSLayoutConstraint constraintWithItem:yellowView ofattribute:0 relatedBy:0 toItem:self attribute:0 multiplier:1 constant:0];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end